﻿using System;
using System.Web;
namespace WebSite.Request
{
    public class RequestHandler : HttpHandlerBase
    {
        /*
         * 用户账号登录，参数为账号密码
         * http://domain/request/login?user={name}&pwd={pwd}
         * demo:http://localhost:1336/request/login?user=debug&pwd=123456
         * 获取用户权限，参数为用户编号
         * http://domain/request/config?id={USERID}
         * demo:http://localhost:1336/request/config?id=af4017b4-c6e7-4580-93ff-b2360af63774
         * 记录操作日志，参数为内容
         * http://domain/request/log?user={user}&type={type}&appid={appid}&content={content}
         * demo:http://localhost:1336/request/log?user=debug&type=1&appid=&content=记录工作日志
         */
        string request = "/request/";
        public override void ProcessRequest(HttpContext context)
        {
            string url = context.Request.Url.ToString();
            string path = context.Request.Path;

            string requestService = path.Replace(request, string.Empty).ToLower();
            string jsonStr = string.Empty;
            object resultObject = null;
            //switch (requestService)
            //{
                
            //}
            if (resultObject is String)
                context.Response.Write(resultObject.ToString());
            else
            {
                jsonStr = ObjectToJSON(resultObject);
                context.Response.Write(jsonStr);
            }
        }
    }
}